/**
 * 
 */
package com.example.config;

import com.example.common.DozerMapper;
import com.example.common.DozerMappingImpl;
import com.google.common.base.Charsets;
import org.hibernate.validator.HibernateValidator;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import java.util.Properties;

/**
 * @author honger.liu
 *
 */
@Configuration
public class MapperConfig {

	@Bean
	public DozerMapper dozerMapper() {
		DozerMappingImpl mapper = new DozerMappingImpl();
		return mapper;
	}

	@Bean
	public LocalValidatorFactoryBean validator(){
		LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
		localValidatorFactoryBean.setProviderClass(HibernateValidator.class);
		localValidatorFactoryBean.setValidationMessageSource(messageSource());
		return localValidatorFactoryBean;
	}

	@Bean
	public ReloadableResourceBundleMessageSource messageSource(){
		ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
		source.setDefaultEncoding("GBK");
		source.setBasename("classpath:valid");
		return source;
	}

	
}
